<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>
  <div id="app">
    {{username}}
  </div>

  <script>

    var user = {
      username: 'chentianyang',
      age: 18

    };

    // Object.freeze(user);

    var vm = new Vue({
      //vue实例挂载的dom ID
      el: "#app",
      data: user,
      myoptions() {
        console.log('myoptions...')
      },
      mounted() {
        setTimeout(() => {
          this.username = 'hanye'
        }, 4000)
      }
    })

    // console.log(vm.username === user.username);

    // console.log(vm.$el === document.getElementById('app'))

    vm.$watch('username', function (newval, oldval) {
      console.log(newval, oldval);
    })

  </script>

</body>

</html>